﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiGenericTexture : OdGiProceduralTexture
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiGenericTexture(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiGenericTexture_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiGenericTexture obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiGenericTexture()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiGenericTexture(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiGenericTexture cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiGenericTexture_cast(OdRxObject.getCPtr(pObj));
			OdGiGenericTexture result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGenericTexture_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGenericTexture_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGenericTexture_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGiGenericTexture createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiGenericTexture_createObject();
			OdGiGenericTexture result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdGiProceduralTexture.Type type()
		{
			OdGiProceduralTexture.Type result = (OdGiProceduralTexture.Type)GlobalsPINVOKE.OdGiGenericTexture_type(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setDefinition(OdGiVariant definition)
		{
			GlobalsPINVOKE.OdGiGenericTexture_setDefinition(this.swigCPtr, OdGiVariant.getCPtr(definition));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGiVariant definition()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiGenericTexture_definition__SWIG_0(this.swigCPtr);
			OdGiVariant result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void definition(out OdGiVariant pDefinition)
		{
			IntPtr zero = IntPtr.Zero;
			try
			{
				GlobalsPINVOKE.OdGiGenericTexture_definition__SWIG_1(this.swigCPtr, out zero);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				pDefinition = (OdGiVariant)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
		}

		public new virtual bool IsEqual(OdGiMaterialTexture texture)
		{
			bool result = GlobalsPINVOKE.OdGiGenericTexture_IsEqual(this.swigCPtr, OdGiMaterialTexture.getCPtr(texture));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiGenericTexture Assign(OdGiGenericTexture texture)
		{
			OdGiGenericTexture result = (OdGiGenericTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGenericTexture_Assign(this.swigCPtr, OdGiGenericTexture.getCPtr(texture)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void copyFrom(OdRxObject pSource)
		{
			GlobalsPINVOKE.OdGiGenericTexture_copyFrom(this.swigCPtr, OdRxObject.getCPtr(pSource));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
